/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author damfercer
 */
@Entity
@Table(name = "candidate_relocating_info")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CandidateRelocatingInfo.findAll", query = "SELECT c FROM CandidateRelocatingInfo c"),
    @NamedQuery(name = "CandidateRelocatingInfo.findByIdCandidateRelocatingInfo", query = "SELECT c FROM CandidateRelocatingInfo c WHERE c.idCandidateRelocatingInfo = :idCandidateRelocatingInfo")})
public class CandidateRelocatingInfo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_CANDIDATE_RELOCATING_INFO")
    private Integer idCandidateRelocatingInfo;
    @JoinColumn(name = "COUNTRY", referencedColumnName = "ID_COUNTRY")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Country country;
    @JoinColumn(name = "CANDIDATE", referencedColumnName = "ID_CANDIDATE")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Candidate candidate;
    @JoinColumn(name = "PROVINCE", referencedColumnName = "ID_PROVINCE")
    @ManyToOne(fetch = FetchType.LAZY)
    private Province province;

    public CandidateRelocatingInfo() {
    }

    public CandidateRelocatingInfo(Integer idCandidateRelocatingInfo) {
        this.idCandidateRelocatingInfo = idCandidateRelocatingInfo;
    }

    public Integer getIdCandidateRelocatingInfo() {
        return idCandidateRelocatingInfo;
    }

    public void setIdCandidateRelocatingInfo(Integer idCandidateRelocatingInfo) {
        this.idCandidateRelocatingInfo = idCandidateRelocatingInfo;
    }

    public Country getCountry() {
        return country;
    }

    public void setCountry(Country country) {
        this.country = country;
    }

    public Candidate getCandidate() {
        return candidate;
    }

    public void setCandidate(Candidate candidate) {
        this.candidate = candidate;
    }

    public Province getProvince() {
        return province;
    }

    public void setProvince(Province province) {
        this.province = province;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCandidateRelocatingInfo != null ? idCandidateRelocatingInfo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        boolean res=false;
        if (object instanceof CandidateRelocatingInfo) {
            CandidateRelocatingInfo other=(CandidateRelocatingInfo)object;
            if(this.getIdCandidateRelocatingInfo()!=null && other.getIdCandidateRelocatingInfo()!=null){
                res=this.getIdCandidateRelocatingInfo().equals(other.getIdCandidateRelocatingInfo());
            }
            else{
                if(this.getProvince()!=null && other.getProvince()!=null){
                    res=this.getCountry().getIdCountry().equals(other.getCountry().getIdCountry()) && this.getProvince().getIdProvince().equals(other.getProvince().getIdProvince());
                }
                else if(this.getProvince()==null && other.getProvince()==null){
                    res=this.getCountry().getIdCountry().equals(other.getCountry().getIdCountry());
                }
            }
        }
        return res;
    }

    @Override
    public String toString() {
        return "entities.CandidateRelocatingInfo[ idCandidateRelocatingInfo=" + idCandidateRelocatingInfo + " ]";
    }
    
}
